package top.system.dept.utils;

/**
 * @author: Amosen
 * @time: 2021-5-16
 */

public class StringUtil {

	public static final String STRING_SEPARATOR = ",";

	public static boolean strCanUse(String str) {
		if (str == null) {
			return false;
		} else if (str.length() == 0 || "".equals(str) || "".equals(str.trim())) {
			return false;
		}
		return true;
	}

	public static boolean checkStrArgs(String...args) {
		for (String arg : args) {
			if (!strCanUse(arg)) {
				return false;
			}
		}
		return true;
	}

	public static String arrayToString(String[] array) {
		if (array == null) {
			return null;
		}
		StringBuilder sb = new StringBuilder();
		for (String str : array) {
			sb.append(str + STRING_SEPARATOR);
		}
		return sb.toString();
	}

	public static String[] stringToArray(String str) {
		if (str == null) {
			return null;
		}
		String replace = str.replace(",", " ");
		String[] rawStrs = replace.split(" ");
		for (String rawStr : rawStrs) {
			rawStr = rawStr.trim();
		}
		return rawStrs;
	}

}
